home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
julian1a
/
julianda.cls
Wrap
Text File
|
1999-10-12
|
3KB
|
111 lines
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "JulianDate"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit
Private Month As String
Private Day As String
Private Year As String
'local variable(s) to hold property value(s)
Private mvarJulian As String 'local copy
Public Property Get Julian() As String
Attribute Julian.VB_Description = "Julian date output"
'Assign the output date string to the public .Julian property
Julian = mvarJulian
End Property
'Creates a Julian date based on current time/date
Public Sub MakeJulianDate()
'Get the date and separate it into its components
Month = Left$(Format$(Now, "mmddyyyy"), 2)
Day = Mid$(Format$(Now, "mmddyyyy"), 3, 2)
Year = Right$(Format$(Now, "mmddyyyy"), 4)
'Determine the base count for figuring Julian date by assigning
'cumulative day count to month #
Select Case Val(Month)
'Jan
Case 1
Month = 0
'Feb
Case 2
Month = 31
'Mar
Case 3
Month = 59
'Apr
Case 4
Month = 90
'May
Case 5
Month = 120
'Jun
Case 6
Month = 151
'Jul
Case 7
Month = 181
'Aug
Case 8
Month = 212
'Sep
Case 9
Month = 243
'Oct
Case 10
Month = 273
'Nov
Case 11
Month = 304
'Dec
Case 12
Month = 334
End Select
'Add the base count and day offset to get the initial Julian date,
'uncompensated for leap years
Month = Str$(Val(Month) + Val(Day))
Select Case Len(Month)
Case 2
Month = "00" & Right$(Month, 1)
Case 3
Month = "0" & Right$(Month, 2)
End Select
'Now check for leap years and adjust the Julian date
'by one to account for Feb 29
If Val(Year) Mod 4 = 0 And Val(Year) Mod 100 = 0 Then
If Val(Year) Mod 400 = 0 And Val(Month) > 59 Then
Month = Str$(Val(Month) + 1)
End If
ElseIf Val(Year) Mod 4 = 0 And Val(Month) > 59 Then
Month = Str$(Val(Month) + 1)
End If
Select Case Len(Month)
Case 1
Month = "00" & Right$(Month, 1)
Case 2
Month = "0" & Right$(Month, 2)
End Select
'assign the juliand date string to the local storage variable
mvarJulian = Year & Right$(Month, 3)
End Sub